<template>
  <Dialog :appDialog="appDialog">
    <div class="content">
      <el-descriptions :column="1" border>
        <el-descriptions-item label="法人姓名" label-align="right">
          {{ formInfo.legal_person_name }}
        </el-descriptions-item>
        <el-descriptions-item label="法人微信号" label-align="right">
          {{ formInfo.legal_person_wechat }}
        </el-descriptions-item>
        <el-descriptions-item label="企业名称" label-align="right">
          {{ formInfo.business_name }}
        </el-descriptions-item>
        <el-descriptions-item label="企业代码类型" label-align="right">
          {{ getCodeTypeName(formInfo.business_code_type) }}
        </el-descriptions-item>
        <el-descriptions-item label="企业代码" label-align="right">
          {{ formInfo.business_code }}
        </el-descriptions-item>
        <el-descriptions-item label="联系电话" label-align="right">
          {{ formInfo.component_phone }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </Dialog>
</template>
<script setup lang="ts">
import Dialog from '@/components/Dialog.vue'
import { ref, reactive, watch } from 'vue'
import { miniAppApplyRegInfo } from '@/api/channelconfig/marketingApplet'


const codeList = reactive<any>([
  {
    name: '统一社会信用代码(18 位)',
    value: 1
  },
  {
    name: '组织机构代码（9 位 xxxxxxxx-x）',
    value: 2
  },
  {
    name: '营业执照注册号(15 位)',
    value: 3
  }
])

const appDialog = reactive<any>({
  visible: false,
  title: '填写内容',
  width: '40%',
  cancelText: '',
  submitText: '',
  id: ''
})

const formInfo = reactive<any>({
  legal_person_name: '',
  legal_person_wechat: '',
  business_name: '',
  business_code_type: '',
  business_code: '',
  component_phone: ''
})

const initData = async () => {
  let res = await miniAppApplyRegInfo({id: appDialog.id})
  Object.assign(formInfo, res)
}

const getCodeTypeName = (code?: any) => {
  let info = codeList.find((el: any) => el.value == code) || {}
  return info.name
}

watch(
  () => appDialog.visible,
  (v) => {
    console.log(v,'vv')
    if(v) {
      initData()
    }
  }
)

defineExpose({
  appDialog
})

</script>
<style lang="scss" scoped>
.content {

}
</style>